package yto.freemarker.springbootstudy.sofa;

import com.alipay.sofa.rpc.config.ConsumerConfig;

/**
 * 服务消费者
 *
 * @author dongxing
 * @create 2018-05-02 15:44
 **/
public class QuickStartClient {

    public static void main(String[] args) {
        ConsumerConfig<HelloService> consumerConfig = new ConsumerConfig<HelloService>()
                .setInterfaceId(HelloService.class.getName())  // 指定接口
                .setProtocol("bolt")  // 指定协议
                .setDirectUrl("bolt://127.0.0.1:9696");  // 指定直连地址

        HelloService helloService = consumerConfig.refer();

        while (true) {
            System.out.println(helloService.sayHello("world"));
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
